package com.zzptc.zzsgz.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;

public class MPAndorid_LineChart extends AppCompatActivity {

    private LineChart lineChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mpandorid__line_chart);
        lineChart = findViewById(R.id.line_Chart);
        ArrayList<Entry> list1=new ArrayList<>();
        list1.add(new Entry(1,3));
        list1.add(new Entry(2,8));
        list1.add(new Entry(3,6));
        list1.add(new Entry(4,4));
        list1.add(new Entry(5,3));
        ArrayList<Entry> list2=new ArrayList<>();
        list2.add(new Entry(1,9));
        list2.add(new Entry(2,4));
        list2.add(new Entry(3,3));
        list2.add(new Entry(4,12));
        list2.add(new Entry(5,4));
        LineDataSet lineDataSet=new LineDataSet(list1,null);
        lineDataSet.setColor(Color.BLUE);
        lineDataSet.setLineWidth(6);
        LineDataSet lineDataSet1=new LineDataSet(list2,null);
        lineDataSet1.setColor(Color.RED);
        ArrayList<ILineDataSet> list_lineDataSet=new ArrayList<>();
        list_lineDataSet.add(lineDataSet);
        list_lineDataSet.add(lineDataSet1);
        LineData lineData=new LineData(list_lineDataSet);

        lineChart.setData(lineData);

        XAxis xAxis= lineChart.getXAxis();
       // xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);



    }
}
